package com.qf.dao;

import com.qf.pojo.entity.Users;
import org.apache.ibatis.annotations.*;

/**
 * @ClassName UserMapper
 * @Description TODO
 * @Author 非乐
 * @Date 2022/9/28 16:47
 * @Version 1.0
 **/
@Mapper
public interface UserMapper {
    //注册
    @Insert("insert into users(user_name,password,user_mail) values(#{userName},#{password},#{userMail})")
    int addUser(Users user);

//   根据用户名查宅
    @Results(id = "userMap",value = {
            @Result(column = "id",property = "id"),
            @Result(column = "user_pic",property = "userPic"),
            @Result(column = "user_name",property = "userName"),
            @Result(column = "user_name",property = "userName"),
            @Result(column = "user_address",property = "userAddress"),
            @Result(column = "password",property = "password"),
            @Result(column = "type",property = "type")
    })
    @Select("select * from users where user_name = #{userName}")
    Users findUserByName(String userName);


//    根据邮箱查找用户
    @ResultMap(value = "userMap")
    @Select("select * from users where user_mail = #{userMail}")
    Users findByEmail(String userMail);
}
